﻿cmake_minimum_required(VERSION 3.3)

list(APPEND CMAKE_MODULE_PATH "C:/Users/Deller/Documents/3rdlibs/share")

project(SunshineDurationSimulation)

#1. glew
find_package(GLEW)
if (NOT TARGET GLEW::glew)
	message(FATAL_ERROR "glew not found")
endif()

#2. OpenGL
find_package(OpenGL REQUIRED)
if (OPENGL_FOUND)
	include_directories(${OPENGL_INCLUDE_DIR})
else()
	message(FATAL_ERROR "opengl not found")
endif()

#3. freeglut
find_package(Freeglut)
if (FREEGLUT_FOUND)
	include_directories(${FREEGLUT_INCLUDE_DIRS})
else()
	message(FATAL_ERROR "Freeglut not found")
endif()

#4. Common
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Common/Include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Common/Include/ImageMagick-6)

#5. OpenCV
find_package(OpenCV)
if (OpenCV_FOUND)
	include_directories(${OpenCV_INCLUDE_DIRS})
else()
	message(FATAL_ERROR "OpenCV not found")
endif()

#6. Assimp
find_package(Assimp)
if (ASSIMP_FOUND)
	include_directories(${ASSIMP_INCLUDE_DIRS})
else()
	message(FATAL_ERROR "Assimp not found")
endif()

set(OGLDEV_LINK_LIBS 	
	${OpenCV_LIBS} 
	${ASSIMP_LIBS} 
	${FREEGLUT_LIBS} 
	GLEW::glew 
	${OPENGL_LIBRARIES}
)

#6. VS create filters
macro(create_filter_by_dir)
	if (MSVC)
		foreach(file ${ARGN})
			get_filename_component(SRC_PATH "${file}" DIRECTORY)
			string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" GROUP "${SRC_PATH}")
			string(REPLACE "/" "\\" GROUP "${GROUP}")
			source_group("${GROUP}" FILES "${file}")
		endforeach()
	endif()
	
	#ARGN 最后一个形参之后的参数列表
	#CMAKE_CURRENT_SOURCE_DIR 表示执行该语句的cmake所在的位置，和定义宏的位置无关
	#string(REPLACE MATCH_STR REPLACE_STR OUTPUT_STR INPUT_STR)
	#source_group(<name> FILES <src>) 把src归到name这个组
endmacro(create_filter_by_dir)

add_subdirectory(Common)

add_subdirectory(ModelGenerator)

add_subdirectory(src)